<%@ page contentType="text/html;charset=utf-8" language="java" %>
<script>
    top.postMessage({
        action: 'onFramePageInit',
        data: {
            title: document.title,
            url: location.href
        }
    }, '*');

    var nextInvokeId = new Date().getTime() * 1000;
    var invokeCallbacks = {};

    function invokeTop(action, data, callback) {
        if (typeof(data) == 'function') {
            callback = data;
            data = null;
        }
        var message = {
            action: action,
            data: data
        };
        if (callback) {
            var invokeId = '#' + (++nextInvokeId);
            message.invokeId = invokeId;
            invokeCallbacks[invokeId] = callback;
        }
        top.postMessage(message, '*');
    }

    window.addEventListener("message", receiveMessage, false);
    function receiveMessage(event) {

        var message = event.data;
        if (message.callbackInvokeId) {
            var callback = invokeCallbacks[message.callbackInvokeId];
            delete invokeCallbacks[message.callbackInvokeId];
            callback(message.actionResult);
            return;
        }
        if (message.action == 'requestBack') {
            history.back();
        }
        if (message.action == "onInitRecipe") {
            top.postMessage({action: "onInitRecipe"}, '*');
        }
    }
</script>
<%if (request.getHeader("User-Agent").contains("Mobile")) {%>
<script type="text/javascript" src="${home}/js/lib/jquery.min.js"></script>
<%--<script type="text/javascript" src="${home}/js/lib/fastclick.js"></script>--%>
<%
    request.setAttribute("inBrowser", false);
} else {%>
<script type="text/javascript" src="${home}/js/lib/jquery.js"></script>
<%--<script type="text/javascript" src="${home}/js/lib/fastclick.js"></script>--%>
<%
        request.setAttribute("inBrowser", true);
    }%>
<script>
    var _home = '${home}';
    var inBrowser = ${inBrowser? 'true': 'false'};
    $(function () {
        $(document.body).append("<div id='page-loading' style='display:none;'>" +
            "<div class='spinner center'>" +
            "<div class='spinner-blade'></div>" +
            "<div class='spinner-blade'></div>" +
            "<div class='spinner-blade'></div>" +
            "<div class='spinner-blade'></div>" +
            "<div class='spinner-blade'></div>" +
            "<div class='spinner-blade'></div>" +
            "<div class='spinner-blade'></div>" +
            "<div class='spinner-blade'></div>" +
            "<div class='spinner-blade'></div>" +
            "<div class='spinner-blade'></div>" +
            "<div class='spinner-blade'></div>" +
            "<div class='spinner-blade'></div>" +
            "</div>" +
            "</div>");
    });
</script>
<script type="text/javascript" src="${home}/js/pub.js?v=109"></script>
<script type="text/javascript" src="${home}/js/app.js?v=109"></script>
